<!doctype html>
<html class="x-admin-sm">
	<head>
		<meta charset="UTF-8">
		<title>宠物领养系统</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="/css/font.css">
		<link rel="stylesheet" href="/css/login.css">
		<link rel="stylesheet" href="/css/xadmin.css">
		<script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
		<script src="/lib/layui/layui.js" charset="utf-8"></script>
		<script src="/js/global.js"></script>
	</head>
	<body class="login-bg">

		<div class="login layui-anim layui-anim-up">
			<div class="message">宠物领养系统</div>
			<div id="darkbannerwrap"></div>
			<input name="account" id="account" placeholder="账号" type="text" lay-verify="required" class="layui-input">
			<hr class="hr15">
			<input name="password" id="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
			<hr class="hr15">
			<input value="登录" id="btn" class="layui-btn" style="width: 340px;height: 50px;font-size: 28px;">
			<hr class="hr20">
			<a href="register.html"><input value="注册" type="button" class="layui-btn" style="width: 340px;height: 50px;font-size: 28px;"></a>
			<hr class="hr20">
		</div>
		<script>
			
			layui.use('form', function(){
			  var form = layui.form;
			  var layer = layui.layer;
			  var $ = layui.jquery;
			  
			  $("#btn").on("click", function () {
				  let account=$("#account").val();
				  let password=$("#password").val();
				  if (!account || !password) {
				  	layer.msg('请填写账号密码和身份，不能为空', {
				  		icon: 5,
				  		time: 2000
				  	});
					return;
					}
			  	$.post('./users/login', {account,password}, function(res) {
			  		if (res.code === 200) {
			  			globalData.setUserInfo(res.data.realname,res.data.userid,res.data.role);
			  			layer.msg(res.msg, {
			  				icon: 1,
			  				time: 2000
			  			}, function() {
			  				window.location.href = "index.html";
			  			});
			  		} else {
			  			layer.msg(res.msg, {
			  				icon: 5,
			  				time: 2000
			  			});
			  		}
			  	}, "json");
			  })
			});
		
		</script>
		<!-- 底部结束 -->
	</body>
</html>
